**************************Table 1 分年统计智能制造企业数目**************************

cd "D:\Statalearning\do\2025\20241223"

use "Data\final\Regression.dta",clear


*计算所有企业数目*
gen n=1
*计算智能制造企业数*
gen ddig=1 if IM!=0
replace ddig=0 if IM==0
*计算非智能制造企业数*
gen nondig=1 if IM==0
replace nondig=0 if IM!=0
*计算深度智能化企业数*
gen dextensive=1 if Extensive_IM!=0
replace dextensive=0 if Extensive_IM==0
*计算广度智能化企业数*
gen dintensive=1 if Intensive_IM!=0
replace dintensive=0 if Intensive_IM==0


bysort year: egen company=sum(n)
bysort year: egen imcompany=sum(ddig)
bysort year: egen nonimcompany=sum(nondig)
bysort year: egen excompany=sum(dextensive)
bysort year: egen incompany=sum(dintensive)

keep year company  imcompany nonimcompany excompany incompany
duplicates drop

export excel using Output\StylizedFacts\Table1.xlsx,replace firstrow(var)

********************Figure 1 2000年深度与广度智能化投入的行业分布*******************

use "Data\final\Regression.dta",clear

gen extensive_exp=exp(Extensive_IM)-1
gen intensive_exp=exp(Intensive_IM)-1

replace cic2="06-11" if cic2=="06"| cic2=="07"| cic2=="08"| cic2=="09"| cic2=="10"| cic2=="11"

replace cic2="44-46" if cic2=="44"| cic2=="45"| cic2=="46"


bysort cic2 year:egen cicextensive=sum(extensive_exp)
bysort cic2 year:egen cicintensive=sum(intensive_exp)

keep year cic2 cicextensive cicintensive
duplicates drop

keep if year==2000

gen cicintensive_new=cicintensive/10000
gen cicextensive_new=cicextensive/10000

graph bar cicintensive_new ,over(cic2, label(angle(45) labsize(2.7))) stack  ytitle(`"{fontface "宋体":深度智能化投入}"' , size(small))   graphregion(fcolor(white) ifcolor(white)  lcolor(white) ilcolor(white)) bgcolor(white)  scheme(s1mono)  ylabel(,nogrid) 
graph save intensive_new2000.gph,replace

graph bar cicextensive_new ,over(cic2, label(angle(45) labsize(2.7))) stack  ytitle(`"{fontface "宋体":广度智能化投入}"' , size(small))   graphregion(fcolor(white) ifcolor(white)  lcolor(white) ilcolor(white)) bgcolor(white)  scheme(s1mono)  ylabel(,nogrid) 
graph save extensive_new2000.gph,replace

graph combine intensive_new2000.gph extensive_new2000.gph,row(2)

********************Table 2 深入看深度和广度的差别双样本t*******************
use "Data\final\Regression.dta",clear
*识别非智能制造企业*
gen nondig=1 if IM==0
replace nondig=0 if IM!=0

logout, save(Output\StylizedFacts\Table2_1) word replace: ttable3 TFP ,by(nondig)

*识别深度智能化企业*
gen dextensive=1 if Extensive_IM!=0
replace dextensive=0 if Extensive_IM==0
*识别广度智能化企业*
gen dintensive=1 if Intensive_IM!=0
replace dintensive=0 if Intensive_IM==0

*删去非智能化企业
drop if dintensive==0&dextensive==0
*删去双智能化企业
drop if dintensive==1&dextensive==1

logout, save(Output\StylizedFacts\Table2_2) word replace: ttable3 TFP ,by(dextensive)



/* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

  Appendix Table 1: Summary Statistics

* - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */

use "Data\final\Regression.dta",clear
* Note: ssc install logout
logout, save(Output\StylizedFacts\Table3) word replace: tabstat TFP IM Extensive_IM Intensive_IM lnage lnage2 lnemployee lnimv_firm lngdp lnpeople lncitywage cpi HHI indemployeeshare indsoeshare indfoeshare , stat(count mean sd min max) col(stat) format(%10.2f)














